package com.threeti.mecool.core.domain.model.basicdata.biz;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
import java.io.Serializable;

/** 通路，即终端 */
@Embeddable
public class Channel implements Serializable {
    @Column(name="CHANNEL_CODE")
    private String code;

    @Column(name="CHANNEL_NAME")
    private String name;

    @Column(name="CHANNEL_ADDRESS")
    private String address;

    @Embedded
//  @AttributeOverride(name="code", column=@Column(name="CHANNEL_CAT_CODE"))
    private ChannelCategory category;

    @Column(name="CHANNEL_SYS_CAT")
    private String sysCategory;

    @Column(name="CHANNEL_ADMIN_DIV_ID")
    private String adminDivId;

    public Channel(String code, String name, String address, ChannelCategory category, String sysCategory, String adminDivId) {
        super();
        this.code = code;
        this.name = name;
        this.address = address;
        this.category = category;
        this.sysCategory = sysCategory;
        this.adminDivId = adminDivId;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public ChannelCategory getCategory() {
        return category;
    }

    public String getSysCategory() {
        return sysCategory;
    }

    public String getAdminDivId() {
        return adminDivId;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public String toString() {
        return "Channel [code=" + code + ", name=" + name + ", address=" + address + ", category=" + category
                + ", sysCategory=" + sysCategory + ", adminDivId=" + adminDivId + "]";
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((code == null) ? 0 : code.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Channel other = (Channel) obj;
        if (code == null) {
            if (other.code != null)
                return false;
        } else if (!code.equals(other.code))
            return false;
        return true;
    }

    Channel() {
        super();
    }


}
